package ru.isys.yoomee.model;

import java.util.Date;

public class ChatItem
{
    private Chat chat;
    private String message;
    private Date date;
    private Yoo owner;
    public ChatItem(Chat chat, String message, Date date, Yoo owner)
    {
        this.chat = chat;
        this.message = message;
        this.date = date;
        this.owner = owner;
    }
    
    public ChatItem(Chat chat, String message, Yoo owner)
    {
        this(chat,message,new Date(),owner);//current time
       
    }
    
    public ChatItem(Chat chat, String message)
    {
        this(chat,message,new Date(),new Yoo(""));//current time, empty nickname
    }
    
    
    public ChatItem(Chat chat)
    {
        this(chat,"",new Date(),new Yoo(""));//current time, empty nickname, empty message(bad)
    }
    
    public ChatItem()
    {
        this(new Chat(""),"",new Date(),new Yoo(""));//current time, empty nickname, empty message(bad)
    }
    
    public Chat getChat()
    {
        return chat;
    }
    public void setChat(Chat chat)
    {
        this.chat = chat;
    }
    public String getMessage()
    {
        return message;
    }
    public void setMessage(String message)
    {
        this.message = message;
    }
    public Date getDate()
    {
        return date;
    }
    public void setDate(Date date)
    {
        this.date = date;
    }
    public Yoo getOwner()
    {
        return owner;
    }
    public void setOwner(Yoo owner)
    {
        this.owner = owner;
    }

    @Override
    public int hashCode()
    {
        final int prime = 31;
        int result = 1;
        result = prime * result + ((chat == null) ? 0 : chat.hashCode());
        result = prime * result + ((date == null) ? 0 : date.hashCode());
        result = prime * result + ((message == null) ? 0 : message.hashCode());
        result = prime * result + ((owner == null) ? 0 : owner.hashCode());
        return result;
    }

    @Override
    public boolean equals(Object obj)
    {
        if (this == obj)
            return true;
        if (obj == null)
            return false;
        if (getClass() != obj.getClass())
            return false;
        ChatItem other = (ChatItem) obj;
        if (chat == null)
        {
            if (other.chat != null)
                return false;
        }
        else if (!chat.equals(other.chat))
            return false;
        if (date == null)
        {
            if (other.date != null)
                return false;
        }
        else if (!date.equals(other.date))
            return false;
        if (message == null)
        {
            if (other.message != null)
                return false;
        }
        else if (!message.equals(other.message))
            return false;
        if (owner == null)
        {
            if (other.owner != null)
                return false;
        }
        else if (!owner.equals(other.owner))
            return false;
        return true;
    }
    
    
}
